package crap;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Swings {
	public static void main(String[] args) {
		JFrame ff = new JFrame();
		
		
		JPanel p = new JPanel();
//		p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
		p.setLayout(new BorderLayout());
		JComponent a = new JComponent() {
			{setPreferredSize(new Dimension(256,256));}
			@Override
			public void paint(Graphics g) {
				g.setColor(Color.red);
				g.fillRect(0, 0, this.getWidth(), this.getHeight());
				// TODO Auto-generated method stub
				super.paint(g);
			}
		};
		JComponent b = new JComponent() {
			{setPreferredSize(new Dimension(256,256));}
			@Override
			public void paint(Graphics g) {
				g.setColor(Color.blue);
				g.fillRect(0, 0, this.getWidth(), this.getHeight());
				// TODO Auto-generated method stub
				super.paint(g);
			}
		};
		
//		p.add(a, BorderLayout.NORTH);
		p.add(b, BorderLayout.SOUTH);
		
		ff.add(p, BorderLayout.CENTER);
		ff.add(a);
		
		ff.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		ff.pack();
		ff.setVisible(true);
	}
}
